package com.shanghaionstar.utils;

import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.widget.TextView;

import com.shanghaionstar.R;

/**
 * 设置字体不同大小
 * Created by Yonglang Hong on 2016/8/1.
 */
public class TextViewUtil {

    public static void setText(TextView tv,String str,String wholeStr){
        SpannableString styledText = new SpannableString(wholeStr);
        styledText.setSpan(new AbsoluteSizeSpan(tv.getResources().getDimensionPixelSize(R.dimen.font_huge)), 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledText.setSpan(new AbsoluteSizeSpan(tv.getResources().getDimensionPixelSize(R.dimen.font_big)), str.length(),wholeStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv.setText(styledText, TextView.BufferType.NORMAL);//若改为SPANNABLE会造成在5.0手机跑马灯效果失效
    }

}
